package com.whu.service.impl;

import com.whu.dao.SupplierRepository;
import com.whu.pojo.Supplier;
import com.whu.service.SupplierServiceInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SupplierService implements SupplierServiceInterface {

    @Autowired
    private SupplierRepository repository;

    @Override
    public List<Supplier> findAll() {
        return repository.findAll();
    }

    @Override
    public Supplier findById(Long id) {
        return repository.findById(id).get();
    }

    @Override
    public List<Supplier> findByName(String supplierName) {
        return repository.findBySupplierName(supplierName);
    }

    @Override
    public void save(Supplier supplier) {
        repository.save(supplier);
    }

    @Override
    public void deleteById(Long id) {
        repository.deleteById(id);
    }
}
